// miniprogram/pages/success/success.js

const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
      info:""
  },

  getItem:function(e){
    var that = this;
    app.getUserToken(function (err, token) {
      wx.request({
        url: app.globalData.url +'/index.php?_m=checkout/order/get_item&order_num=' + e,
        data: {  auth_token: token },
        header: {
          'content-type': 'application/x-www-form-urlencoded'
        },
        method: 'post',
        success: (res) => {
          if (res.data.status == 401) {
            // 清空授权token
            app.globalData.token = null
            wx.removeStorageSync('token')
            that.getItem();
          } else if (res.data.code == 0) {
              that.setData({
                  info:res.data.data
              })
          }
        }
      })
    })  
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getItem(options.order_num)
  },

  goHome(){
    wx.switchTab({
      url:"../index/index"
    })
  },
  checkDd(){

    wx.navigateTo({
      url: "../orderdetail/orderdetail?order_num="+ this.data.info.order_num
    })
  },

  onShareAppMessage: function () {
    app.globalData.uid = app.globalData.uid || wx.getStorageSync('uid') || 0;
    return {
      title: '深圳智汇创想科技有限责任公司员工福利购!',
      path: '/pages/index/index?fid=' + app.globalData.uid
    }
  }
})